<test>
    <create_query>
        CREATE TABLE join_dictionary_source_table (key UInt64, value String)
        ENGINE = MergeTree ORDER BY key;
    </create_query>

    <create_query>
        CREATE DICTIONARY join_hashed_dictionary (key UInt64, value String)
        PRIMARY KEY key 
        SOURCE(CLICKHOUSE(DB 'default' TABLE 'join_dictionary_source_table'))
        LIFETIME(MIN 0 MAX 1000)
        LAYOUT(HASHED());
    </create_query>

    <fill_query>
        INSERT INTO join_dictionary_source_table
        SELECT number, toString(number)
        FROM numbers(1000000);
    </fill_query>
    
    <query>
        SELECT COUNT() 
        FROM join_dictionary_source_table
        JOIN join_hashed_dictionary
        ON join_dictionary_source_table.key = join_hashed_dictionary.key;
    </query>

    <query>
        SELECT COUNT() 
        FROM join_dictionary_source_table
        JOIN join_hashed_dictionary
        ON join_dictionary_source_table.key = toUInt64(join_hashed_dictionary.key);
    </query>

    <drop_query>DROP DICTIONARY IF EXISTS join_hashed_dictionary;</drop_query>
    <drop_query>DROP TABLE IF EXISTS join_dictionary_source_table;</drop_query>
</test>
